/*
 *    Document   : CursosList
 *    Created on : 01/04/2013, 09:34:10
 *    Author     : Fiúza <rbfiuza@gmail.com>
 */

Ext.define('FC.view.CursosProjetoList' ,{
    extend: 'Ext.grid.Panel',

    alias : 'widget.cursosProjetoList',
    title : 'Cursos do Projeto',
    columnLines: true, 
    requires: ['Ext.ux.grid.column.ActionButtonColumn'],
    store:'CursoProjeto',
    plugins: [
                Ext.create('Ext.grid.plugin.CellEditing', {clicksToEdit: 1})
    ],
    features: [{
            ftype: 'summary'
    }],
    selModel: {
        selType: 'cellmodel'
    },
    width: 1200,
//    viewConfig: {
//         forceFit: true
//      },
    autoScroll: true,
    height: 150,
    initComponent: function() {

//        this.tbar = [{
//            text: 'Deletar Diaria', action: 'delete'
//        }];
//    
      this.columns = [
    {
        header: 'id',
        dataIndex: 'id', 
        sortable: false,
        hideable: false,
        hidden:true

    },
    {
        header: 'idProjeto',
        dataIndex: 'idProjeto', 
        sortable: false,
        hideable: false,
        hidden:true

    }    
    ,{
        header: 'listPolos',
        dataIndex: 'listPolos', 
        sortable: false,
        hideable: false,
        hidden:true
    }    
    ,{
        header: 'Curso', 
        dataIndex: 'curso',
        sortable: false,
        hideable: false,
        flex: 1
      }
    ,{
        header: 'Nível',
        dataIndex: 'nivel',
        sortable: false,
        hideable: false

    }
    ,{
            header: 'Cursista',
            dataIndex: 'qntCursista', 
            sortable: false,
            hideable: false,
            xtype: 'numbercolumn' 
            ,format:'0'
//            ,editor:{
//                allowBlank:false
//            }

        }
,{
        header: 'Número de Polos',
        dataIndex: 'qntPolos', 
        sortable: false,
        hideable: false,
        xtype: 'numbercolumn',      
        format:'0',
        flex: 1
//        ,editor:{
//            allowBlank: false
//        }
    }        
    ,{
        header: 'Carga Horaria',
        dataIndex: 'cargaHoraria', 
        sortable: false,
        hideable: false,
        xtype: 'numbercolumn', 
        format:'0'
//        renderer: Ext.util.Format.numberRenderer('0,000/i')
//        ,editor: {
//            allowBlank: false          
//        }

            }
,{
        header: 'Módulos',
        dataIndex: 'modulos', 
        sortable: false,
        hideable: false,
        xtype: 'numbercolumn',    
        format:'0',
        flex: 1
//        ,editor:{
//            allowBlank: false
//        }
}    
    ,{
        header: 'Duração em Meses',
        dataIndex: 'qntMeses', 
        sortable: false,
        hideable: false,
        xtype: 'numbercolumn' 
        ,format:'0'
//        ,editor:{
//            allowBlank:false
//        }
        
    }
,{
        header: 'Vagas Total',
        dataIndex: 'qntVagaTotal', 
        sortable: false,
        hideable: false,
        xtype: 'numbercolumn',      
        format:'0'
    }
    ,{
        
        xtype:'actionbuttoncolumn',
        header: 'Deletar',    
        sortable: false,
        hideable: false,
//        flex: 1,    
        width: 50,
        items: [{
            iconCls: 'icon-delete',
//            action: 'sell'
        handler:  function(grid, rowIndex, colIndex) {
                    this.fireEvent('removeCurso', rowIndex);
//                    var rec = grid.getStore().removeAt(rowIndex);      
//                    grid.getStore().sync();
//                    this.getForm().reset();

                var element = Ext.getCmp('cursosProjetoList');
                element.getStore().load({
                    params: {
                        idprojeto: FC.model.Global.idProjeto
                    }
                });
                
                var curso = Ext.getCmp('cursoprojetolist');
                curso.getForm().reset();
        }
        }]
    }
];
 
this.callParent(arguments);
},
   
formatDate: function(value){
    return value ? Ext.Date.dateFormat(value, 'd M, Y') : '';
},
    
    changeCargaHoraria: function(val){
        
        return val+".78";
        
    }

});